/**
 * Copyright 2011 Joe Choi, All rights reserved.
 */
package tec.encode.han;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import tec.encode.FileUtil;

/**
 * @author Joe Choi
 */
public class CodeUtil {
	public static boolean isHan(char c) {
		return(c >= 0x4E00 && c <= 0x9FCF);
	}
	
	public static List<Character> loadSimplified() throws IOException {
		return(filterNonHan(FileUtil.loadChar("cfg/sc-utf8.tab", "UTF8")));		
	}

	public static List<Character> loadTraditional() throws IOException {
		return(filterNonHan(FileUtil.loadChar("cfg/tc-utf8.tab", "UTF-8")));
	}
	
	private static List<Character> filterNonHan(final List<Character> chars) {
		List<Character> filtered = new ArrayList<Character>();
		for(char c : chars) if(isHan(c)) filtered.add(c);
		return(filtered);
	}
}